<script>
export default {
  name: "Header",

  props: {
    collapseBtnClass: String,
    collapse: Function
  },
  methods: {
    logout(){
      this.$router.push("/login")
      localStorage.removeItem("user")
      this.$message.success("退出成功")
    },
    personInfo(){
      this.$router.push('/person');
    }
  },
  data() {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem( "user")) : {}
    }
  },

}
</script>

<template>
  <div style="line-height: 60px; display: flex">

    <div style="flex: 1;">
      <span :class="collapseBtnClass" style="cursor: pointer; font-size: 18px" @click="collapse"></span>
      <el-breadcrumb separator-class="el-icon-arrow-right" style="display: inline-block; margin-left: 15px">
        <el-breadcrumb-item :to="{ path: '/' }">返回首页</el-breadcrumb-item>


      </el-breadcrumb>
    </div>
    <el-dropdown style="width: 70px; cursor: pointer">
      <div style="display: inline-block">
<!--        <img :src="user.avatarUrl" alt=""-->
<!--             style="width: 30px; border-radius: 50%; position: relative; top: 10px; right: 5px">-->

        <span>{{ user.username }}</span>
        <i class="el-icon-arrow-down" style="margin-left: 5px"></i>
      </div>
      <el-dropdown-menu slot="dropdown" size="medium">
        <el-dropdown-item @click="personInfo">
        <span style="text-decoration: none" @click="personInfo">个人信息</span>
        </el-dropdown-item>
        <el-dropdown-item>
          <span style="text-decoration: none" @click="logout">退出</span>
        </el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<style scoped>

</style>